
#pragma once

#include <stdio.h>

#include "core/olisp_core.h"
#include "utility/olisp_quote_mgr.h"
#include "interpreter/olisp_interpreter.h"

/*
 * represents a dumpers
 */
interpreter_t dump_error_handler;

/*
 * represents context of the reader who performs lexical analysis
 */
typedef struct
{
    /*
     * file stream from which reader gets symbols
     */
    FILE *          stream;

    /*
     * the name of the stream
     */
    const char *    stream_name;

    /*
     * position in the stream
     */
    int             line;
    int             pos;

    /*
     * represents just a handler,
     * who dumps an information about parsing
     * only interpreter::message method is used
     */
    interpreter_t * err_handler;

#ifdef LISP_FEAT_QUOTE_SUPPORT
    /*
     * represents a quote manager
     */
    lisp_quote_mgr_t * quote_mgr;
#endif

    /* last character which shall be returned
     */
    int             ungetc;
} reader_context;

/*
 * reads certain element from a file stream or string, using start_line/start_pos
 * as a locations of a position
 * @ctx         stream from which certain element will be read
 * @return      list if reading succeeds
 */
obj_t * read_elem( reader_context * ctx );
